// Copyright 2022 jeff.li. and/or its affiliates.

#pragma once

#include <tbir/ir/op_attr_types.h>
#include <tbir/ir/op_expr.h>

namespace tbir::ir::builtin {

    using ::tbir::runtime::Array;

#define TBIR_IR_DEFINE_HLO_BUILTIN_FUNC(OpName) \
  const Op& OpName() {                                \
    static const Op& op = Op::Get("ir." #OpName);     \
    return op;                                        \
  }                                                   \
  TBIR_IR_REGISTER_OP("ir." #OpName)

/******************************************************************************
 * Explicit Container builtin functions
 *****************************************************************************/

#define TBIR_IR_DEFINE_HLO_BUILTIN_FUNC_EXPLICIT(OpName, KernelMethod)          \
  TBIR_IR_DEFINE_HLO_BUILTIN_FUNC(OpName)                                       \
      .set_attr<TCallEffectKind>("TCallEffectKind", Integer(CallEffectKind::kOpaque)) \
      .set_attr<TGlobalIsExplicitContainerOp>("TGlobalIsExplicitContainerOp", true)   \
      .set_attr<TKernelMethodName>("TKernelMethodName", #KernelMethod)

/******************************************************************************
 * Generic Container builtin functions
 *****************************************************************************/
#define TBIR_IR_DEFINE_HLO_BUILTIN_FUNC_GENERIC(Prefix, OpName)                 \
  TBIR_IR_DEFINE_HLO_BUILTIN_FUNC(Prefix##_##OpName)                            \
      .set_attr<TCallEffectKind>("TCallEffectKind", Integer(CallEffectKind::kOpaque)) \
      .set_attr<TGlobalIsGenericBuiltinOp>("TGlobalIsGenericBuiltinOp", true)

}  // namespace tbir::ir::builtin
